// miniprogram/pages/doctor/caseDetail.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    caseDetail: {}
  },
  formSubmit: function(e){
    let treament = e.detail.value
    wx.showLoading()
    wx.cloud.callFunction({
      name: 'patient',
      data: {
        action: 'modifyCase',
        _id:this.data.caseDetail._id,
        state:'已处置',
        doctorTreatment: treament.doctorTreatment
      },
      success: res => {
        // wx.redirectTo({
        //   url: 'caseList',
        // })
      },
      fail: err => {
        wx.showToast({
          icon: 'none',
          title: '提交失败，请重试',
        })
      },
      complete: () => {
        wx.hideLoading()
      }
    })

  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let caseDetail={}
    app.globalData.cases.forEach((item)=>{
      if (item._id == options._id) caseDetail = item
    })
    this.setData({caseDetail})
  },
})